﻿using UnityEngine;

namespace VCity
{
    public class AdsInteractable : MonoBehaviour
    {
        public AdsBoard adsBoard;

        public bool HasHypperLink => adsBoard.data.HasLink;

        private void OnValidate()
        {
            // auto find target
            if (adsBoard == null)
            {
                adsBoard = GetComponent<AdsBoard>();
                if (adsBoard == null && gameObject.transform.parent != null)
                    adsBoard = GetComponentInParent<AdsBoard>();
            }
        }

        public void OnClick()
        {
            adsBoard?.OnClick();
        }
    }
}